package com.fizzkai.mapper;

import com.fizzkai.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName UserMapper
 * @Description TODO
 * @Author weijh3
 * @Date 2018/11/26 下午6:31
 * @Version 1.0
 **/
@Mapper
public interface UserMapper {

    @Select("SELECT * FROM `user` limit 10")
    @Results({
            @Result(column = "platform_id", property = "platformId"),
            @Result(column = "user_status", property = "userStatus")
    })
    List<User> findAll();

    @Insert("INSERT INTO `user`(`nuid`, `puid`, `platform_id`, `user_status`) VALUES (#{nuid},#{puid},#{platformId},#{userStatus})")
    void addOne(User user);

    @Select("SELECT * FROM `user` where nuid = #{id} limit 10")
    @Results({
        @Result(column = "platform_id", property = "platformId"),
        @Result(column = "user_status", property = "userStatus")
    })
    List<User> get(Long id);

    @Select("SELECT * FROM `user` where nuid in (#{min}, #{max}) limit 10")
    @Results({
        @Result(column = "platform_id", property = "platformId"),
        @Result(column = "user_status", property = "userStatus")
    })
    List<User> testIn(@Param("min") Long min, @Param("max") Long max);

}
